package com.liuyi.framework;
import com.liuyi.framework.web.LiuyiWebMvcConfig;
import com.liuyi.framework.web.note.NoteStorageValition;
import com.liuyi.framework.web.note.NoteUrl;
import com.liuyi.framework.web.note.NoteUrlStorage;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * LiuyiFramework 配置
 * </p>
 *
 * @author Mr.Fmy
 * @since 2020-12-11
 */
public class LiuyiFrameworkConfig {


    @Bean
    @ConditionalOnProperty(name = "liuyi.webConfig", havingValue = "true", matchIfMissing = true)
    public LiuyiWebMvcConfig liuyiWebMvcConfig() {
        return new LiuyiWebMvcConfig();
    }

    @Bean
    @ConditionalOnMissingBean
    public NoteStorageValition noteStorageValition(){
        return new NoteStorageValition() {
            @Override
            public String get(String type, String phone) {
                return null;
            }

            @Override
            public void remove(String type, String phone) {

            }

            @Override
            public String getPhone(NoteUrl noteUrl, HttpServletRequest request) {
                return null;
            }

            @Override
            public String getNoteCode(HttpServletRequest request) {
                return null;
            }

            @Override
            public void setValitonFail(NoteUrl noteUrl, String phone) {

            }

            @Override
            public int getValitionCount(NoteUrl noteUrl, String phone) {
                return 0;
            }
        };
    }

    @Bean
    @ConditionalOnMissingBean
    public NoteUrlStorage noteUrlStorage(){
        return new NoteUrlStorage() {
            @Override
            public List<NoteUrl> getNoteUrls() {
                return null;
            }

            @Override
            public NoteUrl getUrl(String uri) {
                return null;
            }
        };
    }
}
